<?php
 #############################################################################
 # IMDBPHP                              (c) Giorgos Giagas & Itzchak Rehberg #
 # written by Giorgos Giagas                                                 #
 # extended & maintained by Itzchak Rehberg <izzysoft AT qumran DOT org>     #
 # http://www.izzysoft.de/                                                   #
 # ------------------------------------------------------------------------- #
 # This program is free software; you can redistribute and/or modify it      #
 # under the terms of the GNU General Public License (see doc/LICENSE)       #
 #############################################################################

 /* $Id: imdb_request.class.php 213 2009-05-24 14:15:42Z izzy $ */

class IMDB_Request extends BrowserEmulator{
	var $maxsize = 100000;
	/** Constructor: Initialize the BrowserEmulator
	 *  No need to call this.
	 * @constructor IMDB_Request
	 */
	function IMDB_Request($url){
	  $this->BrowserEmulator();
	  $this->urltoopen = $url;
	}
	/** Send a request to the IMDB site
	 * @method sendRequest
	 * @return boolean success
	 */
	function sendRequest(){
	  $this->fpopened = $this->fopen($this->urltoopen);
	  if ($this->fpopened!==false) return true;
	  return false;
	}
	/** Get the Response body
	 * @method getResponseBody
	 * @return string page
	 */
	function getResponseBody(){
	  $page = "";
	  if ($this->fpopened===FALSE) return $page;
	  while (!feof ($this->fpopened)) {
		$page .= fread ($this->fpopened, 1024);
	  }
	  return $page;
	}
	/** Set the URL we need to parse
	 * @method setURL
	 */
	function setURL($url){
	  $this->urltoopen = $url;
	}
	/** Obtain the response header
	 * @method getresponseheader
	 * @param optional string header
	 * @return string header
	 */
	function getresponseheader($header = false){
	  $headers = $this->getLastResponseHeaders();
	  foreach ($headers as $head){
		if ( is_integer(strpos ($head, $header) )){
		  $hstart = strpos ($head, ": ");
		  $head = trim(substr($head,$hstart+2,100));
		  return $head;
		}
	  }
	}
}
